//创建一个定时器，3s/次
const downLoadInterval = setInterval(getExcelStutus, 3000);
//定时器下载文件
const timerDownLoad = function getExcelStutus() {
    const pathName = document.location.toString();
    const index = findStrIndex(pathName, "/", 3);
    let result = (pathName.substr(0, index + 1)) + "/tm/tm_getExcelStatus.action";
    $.ajax({
        type: 'post',
        url: result,
        datatype: "json",
        data: {
            "id": excelId
        },
        success: function (data) {
            if (data.status === 1) {
                if (data.path != null) {
                    const path = data.path;
                    result = (pathName.substr(0, index + 1)) + "tm/tm_getExcel.action";
                    console.log("下载文件")
                    postDownloadFile(result, path);
                    //清除定时器
                    window.clearInterval(downLoadInterval);
                }
            }
        },
        error: function (data) {
            alert("ERROR")
        }
    })
};

//post请求下载文件（浏览器自动弹出下载）
const postDownloadFile = (action, path) => {
    const form = document.createElement('form');
    form.action = action;
    form.method = 'post';
    form.target = 'blank';
    const input = document.createElement('input');
    input.type = 'hidden';
    input.name = "path";
    input.value = path;
    form.appendChild(input);
    document.body.appendChild(form);
    form.submit();
    document.body.removeChild(form);
}